import React, { Component } from 'react'
import { Route, Switch } from 'react-router-dom'
// 路由组件放在pages文件夹
import Home from './pages/Home'
import About from './pages/About'
// 一般组件放在components文件夹
import Header from './components/Header'
import MyNavLink from './components/MyNavLink'
import Test from './components/Test'

export default class App extends Component {
  render() {
    return (
      <div>
        <div className="row">
          <div className="col-xs-offset-2 col-xs-8">
            <Header></Header>
          </div>
        </div>
        <div className="row">
          <div className="col-xs-2 col-xs-offset-2">
            <div className="list-group">
              {/* 在React中靠路由链接实现切换组件--编写路由链接 */}
              {/* <Link className="list-group-item" to="/about">About</Link>
              <Link className="list-group-item" to="/home">Home</Link> */}
              {/* 高亮版本 */}
              {/* 可以自定义高亮class类名  activeClassName="current"*/}
              {/* <NavLink activeClassName="current" className="list-group-item" to="/about">About</NavLink>
              <NavLink activeClassName="current" className="list-group-item" to="/home">Home</NavLink> */}
              {/* 封装NavLink */}
              <MyNavLink to="/about">About</MyNavLink>
              <MyNavLink to="/home">Home</MyNavLink>

            </div>
          </div>
          <div className="col-xs-6">
            <div className="panel">
              <div className="panel-body">
                {/* 注册路由 */}
                <Switch>
                  <Route path="/about" component={About} />
                  <Route path="/home" component={Home} />
                  {/* 匹配到路由后，不会去继续匹配 */}
                  <Route path="/home" component={Test} />
                </Switch>
              </div>
            </div>
          </div>
        </div>
      </div>
    )
  }
}
